package com.example.administrator.runbook.fragments.community.model;

import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;

/**
 * Created by Administrator on 2016/11/8.
 */

public class Tweets {
//    user
//    _id: "578135b526d46cd970c089a3",
//    avatar: "/avatar/32/57/3257dc02aadcdf282cf92d69847b5ec5",
//    nickname: "八云红(墨)",
//    type: "normal",
//    lv: 7,
//    gender: "male"

//    title: "细思极恐小故事",
//    content: "1、瀑布自杀者 爸爸因为工作需要暂时不在密歇根，我们去波特兰看他。妈妈、弟弟和我花了10天时间，玩遍了俄勒冈州和华盛顿州。最后我们到了马特诺玛瀑布——一个著名的州立公园和观光胜地。 当我们回到密歇根，爸爸一边翻看相机里的照片，一边听新闻，新闻播报说那天瀑布那死了人。有人在瀑布那自杀并不稀奇，但他有点好奇发生自杀事件的时间；由于相机带有时间标记功能，于是他开始翻找相关照片。 他找到了一张照片，拍",
//    post: null,
//    votes: [ ],
//    deleted: false,
//    isHot: true,
//    score: 0,
//    commented: 38,
//    retweeted: 41,
//    type: "ARTICLE",
//    created: "2016-11-07T02:50:26.814Z",
//    _id: "581febf2c8f5d2f620b4ef29",
//    hotAt: "2016-11-07T06:09:21.087Z",
//    refTweet: null,
//    from: null

    private String _id;
    private String avatar;
    private String nickname;
    private String type;
    private String lv;
    private String gender;
    private String title;
    private String content;
    private String commented;
    private String retweeted;
    private String created;
    private String id;

    public String get_id() {
        return _id;
    }

    public void set_id(String _id) {
        this._id = _id;
    }

    public String getAvatar() {
        return "http://statics.zhuishushenqi.com" + avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public String getCommented() {
        return commented;
    }

    public void setCommented(String commented) {
        this.commented = commented;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getCreated() {
        return created;
    }

    public void setCreated(String created) {
        this.created = created;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getLv() {
        return lv;
    }

    public void setLv(String lv) {
        this.lv = lv;
    }

    public String getNickname() {
        return nickname;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    public String getRetweeted() {
        return retweeted;
    }

    public void setRetweeted(String retweeted) {
        this.retweeted = retweeted;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getData(String created) {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'kk:mm:s.S'Z'", Locale.CANADA);
        Calendar date = Calendar.getInstance();
        date.setTime(format.parse(created, new ParsePosition(0)));
        Calendar now = Calendar.getInstance();
        now.setTime(new Date());

        int year = now.get(Calendar.YEAR) - date.get(Calendar.YEAR);
        int month = now.get(Calendar.MONTH) - date.get(Calendar.MONTH);
        int day = now.get(Calendar.DAY_OF_MONTH) - date.get(Calendar.DAY_OF_MONTH);

        if (year > 0) {
            return year + "年前";
        }
        if (month > 0) {
            return month + "月前";
        }
        if (day == 2) {
            return "前天";
        }
        if (day > 1) {
            return day + "天前";
        } else if (day == 1) {
            return "昨天";
        } else if (day == 0) {
            return "今天";
        }
        return "";
    }
}
